using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Xfinity.Rendering.Sfx
{
    public class Flash : DrawableGameComponent
    {
        public Flash(Game game)
            : base(game)
        {

        }
        public Flash(Game game, TimeSpan totalDuration, TimeSpan rampUpDuration, TimeSpan whiteOutDuration, Color tint)
            : base(game)
        {
            this.totalDuration = totalDuration;
            this.rampUpDuration = rampUpDuration;
            this.whiteOutDuration = whiteOutDuration;
            this.tint = tint;
        }
        private double runTime = 0;
        private ContentManager content;
        public override void Initialize()
        {
            content = new ContentManager(Game.Services);
            base.Initialize();
        }
        protected override void LoadGraphicsContent(bool loadAllContent)
        {
            if (loadAllContent)
            {
                flashTexture = content.Load<Texture2D>("Content/Textures/Flash");
            }
            base.LoadGraphicsContent(loadAllContent);
        }
        private Texture2D flashTexture;
        public override void Update(GameTime gameTime)
        {
            runTime += gameTime.ElapsedRealTime.TotalMilliseconds;
            if (runTime<=this.rampUpDuration.TotalMilliseconds)
            {
                RampUpFlash();
            }
            else if(runTime <= whiteOutDuration.TotalMilliseconds)
            {
                WhiteOut();
            }
            else if (runTime<=totalDuration.TotalMilliseconds)
            {
                FadeOut();
            }
            else
            {
                Reset();
            }
            base.Update(gameTime);
        }
        private Vector2 currentSize=Vector2.Zero;
        public override void Draw(GameTime gameTime)
        {
            
            base.Draw(gameTime);
        }

        private void RampUpFlash()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private void WhiteOut()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private void FadeOut()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private void Reset()
        {
            throw new Exception("The method or operation is not implemented.");
        }
        /// <summary>
        /// 
        /// </summary>
        public Texture2D FlashTexture
        {
            get { return flashTexture; }
            set { flashTexture = value; }
        }
        private TimeSpan totalDuration = TimeSpan.FromMilliseconds(400);

        /// <summary>
        /// 
        /// </summary>
        public TimeSpan TotalDuration
        {
            get { return totalDuration; }
            set { totalDuration = value; }
        }
        private TimeSpan rampUpDuration = TimeSpan.FromMilliseconds(150);

        /// <summary>
        /// 
        /// </summary>
        public TimeSpan RampUpDuration
        {
            get { return rampUpDuration; }
            set { rampUpDuration = value; }
        }

        private TimeSpan whiteOutDuration = TimeSpan.FromMilliseconds(150);

        /// <summary>
        /// 
        /// </summary>
        public TimeSpan WhiteOutDuration
        {
            get { return whiteOutDuration; }
            set { whiteOutDuration = value; }
        }
        private Color tint = new Color(255, 255, 245);

        /// <summary>
        /// 
        /// </summary>
        public Color Tint
        {
            get { return tint; }
            set { tint = value; }
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

    }
}
